import request from '@/utils/request'

/**
 * 获取公司的部门
 * @returns
 */
export function getDepartments() {
  return request({
    url: '/company/department'
  })
}

/**
 *添加子部门
 * @param {*} data
 * @returns
 */
export function addDepartments(data) {
  return request({
    url: '/company/department',
    method: 'post',
    data
  })
}

/**
 * 根据 id 查询指定的部门信息 (编辑子部门的数据回填)
 * @param {*} id
 * @returns
 */
export function getDepartmentsDetail(id) {
  return request({
    url: `/company/department/${id}`
  })
}

/**
 * 编辑子部门
 * @param {*} data
 * @returns
 */
export function updateDepartments(data) {
  return request({
    url: `/company/department/${data.id}`,
    method: 'put',
    data
  })
}

/**
 * 删除子部门
 * @param {*}
 * @returns
 */
export function deleteDepartments(id) {
  return request({
    url: `/company/department/${id}`,
    method: 'delete'
  })
}
